package com.lyl.xxx.modules.system.account.service.impl;

import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.lyl.xxx.modules.system.account.dao.SysOperLogDao;
import com.lyl.xxx.modules.system.account.entity.SysOperLog;
import com.lyl.xxx.modules.system.account.service.SysOperLogService;
import com.lyl.xxx.modules.web.montior.model.dto.SysOperLogListDTO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 操作日志记录(SysOperLog)表服务实现类
 *
 * @author Mr Luo
 * @since 2022-10-14 10:15:48
 */
@Service("sysOperLogService")
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogDao, SysOperLog> implements SysOperLogService {

    @Override
    public PageInfo<SysOperLog> list(Integer pageNo, Integer pageSize, SysOperLogListDTO dto) {
        PageMethod.startPage(pageNo,pageSize);
        List<SysOperLog> sysOperLogs = lambdaQuery()
                .like(CharSequenceUtil.isNotBlank(dto.getTitle()),SysOperLog::getTitle,dto.getTitle())
                //.like(CharSequenceUtil.isNotBlank(dto.getMethod()),SysOperLog::getMethod,dto.getMethod())
                .like(CharSequenceUtil.isNotBlank(dto.getOperName()),SysOperLog::getOperName,dto.getOperName())
                .eq(ObjectUtil.isNotEmpty(dto.getStatus()),SysOperLog::getStatus,dto.getStatus())
                .eq(ObjectUtil.isNotEmpty(dto.getBusinessType()),SysOperLog::getBusinessType,dto.getBusinessType())
                .ge(CharSequenceUtil.isNotBlank(dto.getStartTime()),SysOperLog::getOperTime,dto.getStartTime())
                .le(CharSequenceUtil.isNotBlank(dto.getEndTime()),SysOperLog::getOperTime,dto.getEndTime())
                .orderByDesc(SysOperLog::getOperTime).list();
        return PageInfo.of(sysOperLogs);
    }
}

